package StudyCode.summary.utf;

import java.io.UnsupportedEncodingException;
import java.util.Arrays;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class CreateUTF8TextByConvertingString {
	public static void main(String[] args) {
		System.out.println(System.getProperty("file.encoding"));
		String original = new String("A" + "\u00ea" + "\u00f1" + "\u00fc" + "C");

		System.out.println("原始 = " + original);
		System.out.println();

		try {
			byte[] utf8Bytes = original.getBytes("UTF8");
			byte[] defaultBytes = original.getBytes();

			String roundTrip = new String(utf8Bytes, "UTF8");
			System.out.println("UTF8编码文本 = " + roundTrip);

			System.out.println();
			System.out.println(Arrays.toString(utf8Bytes) + ":utf8字节");
			System.out.println();
			System.out.println(Arrays.toString(defaultBytes) + ":默认字节");
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}

	}
}
